package com.tuju.jetpackfirstdemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.tuju.jetpackfirstdemo.R;
import com.tuju.jetpackfirstdemo.utils.KeyWordUtil;

import java.util.Arrays;

public class SearchKeyActivity extends AppCompatActivity {

    private EditText et_search;
    private Button btn_search;
    private TextView tv_content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_key);
        initView();
    }

    private void initView() {
        et_search = findViewById(R.id.et_search);
        btn_search = findViewById(R.id.btn_search);
        tv_content = findViewById(R.id.tv_content);

        btn_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String keyWord = et_search.getText().toString().trim();
                String contentStr = "646929482";
                tv_content.setText(KeyWordUtil.matcherSearchTitle(Color.BLUE, contentStr, Arrays.asList(-1, 4, 4, 5, 6, 7, 9)));
            }
        });
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, SearchKeyActivity.class);
        context.startActivity(intent);
    }
}
